﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Freedom.Models.ViewModels;
using Freedom.Models.Interfaces;
using Freedom.Models.Services;
using Freedom.Models;

namespace Freedom.Controllers
{
    /// <summary>
    ///  服务控制器
    /// autor: Penn Yao 
    /// </summary>
    [HandleError]
    public class ServicesController : Controller
    {
        ServicesViewModel viewModel; 
        IServiceInfoService serviceInfoService;

        public ServicesController()
        {
            if (viewModel == null)
                viewModel = new ServicesViewModel();
            if (serviceInfoService == null)
                serviceInfoService = new ServiceInfoService();
        }

        public ActionResult Index()
        {
            List<tb_ServiceInfo> serviceInfoList = null;
            if (serviceInfoService != null)
                serviceInfoList = serviceInfoService.getAllInfo().ToList();

            if (viewModel != null)
                viewModel.serviceInfoList = serviceInfoList;

            return View(viewModel);
        }
    }
}
